-
Notifications
You must be signed in to change notification settings - Fork 407
Expose counterparty forwarding info in ChannelDetails #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose counterparty forwarding info in ChannelDetails #841
Conversation
7bb9bfb
to
9943259
Compare
Codecov Report
@@ Coverage Diff @@
## main #841 +/- ##
==========================================
+ Coverage 90.64% 91.22% +0.58%
==========================================
Files 50 51 +1
Lines 26843 29055 +2212
==========================================
+ Hits 24331 26506 +2175
- Misses 2512 2549 +37
Continue to review full report at Codecov.
|
9943259
to
d82da70
Compare
d82da70
to
98f5907
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to resuscitate this, almost good to me
pub fn channel_update(&mut self, msg: &msgs::ChannelUpdate) -> Result<(), ChannelError> { | ||
let usable_channel_value_msat = (self.channel_value_satoshis - self.counterparty_selected_channel_reserve_satoshis) * 1000; | ||
if msg.contents.htlc_minimum_msat > usable_channel_value_msat { | ||
return Err(ChannelError::Close("Minimum htlc value is greater than channel value".to_string())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check is purposeful to make sure when we initiate channel with respect our own config or that other counterparty don't waste time/fees with an unroutable channel, but better to move it in new_from_req
/new_outbound
, not already present ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check is present in new_from_req
(new_outbound
isn't parameterized by htlc_min_msat
). Why wouldn't we also check here, though? (Fyi, you wrote this check originally 😛)
@@ -281,6 +281,13 @@ impl HTLCCandidate { | |||
} | |||
} | |||
|
|||
#[derive(Clone)] | |||
pub struct CounterpartyForwardingInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look on #207, effectively this make sense to learn counterparty forwarding policy on this link to communicate a routing hint to a payee. I think this struct should document this usage, as otherwise it's a bit confusing why we need to observe peer's channel_update
on a local channel.
Should we also add htlc_maximum_msat
? Don't issue an invoice with an amount above max otherwise your hint is useless ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct should document this usage, as otherwise it's a bit confusing why we need to observe peer's channel_update on a local channel.
Documented!
Should we also add htlc_maximum_msat ? Don't issue an invoice with an amount above max otherwise your hint is useless ?
Hm, but with MPP, the total invoice amount may violate an individual channel's htlc_max_msat
but not the single payment path that uses said channel. 🤔
9218c57
to
aaf5c4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a few doc nits, but dont bother unless you think you should or you're addressing other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits but wondering if failures handling in the router should dictate if the channel manager should still handle the message. See comment.
self.message_handler.chan_handler.handle_channel_update(&peer.their_node_id.unwrap(), &msg); | ||
let should_forward = match self.message_handler.route_handler.handle_channel_update(&msg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If checks in route_handler
fail, should we still send this message to chan_handler
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd need some way to differentiate "we haven't seen a channel_announcement/the channel is private" as a failure from "invalid signature" or other failures. We /could/ check the signature in ChannelManager, but we know it came directly from our peer, so not sure if we need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you are saying for this particular message. Though I do wonder more broadly if we are expecting custom handler implementations to re-implement all BOLT checks or if there is some subset we should check regardless of implementation. Definitely outside the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, thats a good question. I kinda figure there's relatively limited uses for implementing a full custom message handler, and its more about the message handlers being optional/dummy in cases where, eg, you don't want to have a network graph so I was never too worried about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the wrapper approach in a similar vein as Read
that I had mentioned elsewhere may be sufficient.
c26b951
to
84836d5
Compare
67c7989
to
4547cab
Compare
This will be filled in in upcoming commits, then exposed in ChannelDetails to allow constructing route hints for invoices. Also update the cltv_expiry_deta comment in msgs::ChannelUpdate Co-authored-by: Valentine Wallace <[email protected]> Co-authored-by: Antoine Riard <[email protected]>
This will be used to expose forwarding info for route hints in the next commit. Co-authored-by: Valentine Wallace <[email protected]> Co-authored-by: Antoine Riard <[email protected]>
Useful for constructing route hints for private channels in invoices. Co-authored-by: Valentine Wallace <[email protected]> Co-authored-by: Antoine Riard <[email protected]>
4547cab
to
c318ad8
Compare
CI passed ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only changes since Jeff's ACK were two small doc fixes.
Supersedes #207. Tested in the sample :)